<?php
include("../config.php");
include("../include/db_connect.php");
include("../include/session.php");
include("../include/common.php");
include("../include/search.php");
include("../include/item.php");

if(isset($_SESSION['user_id'])) {
	$userInfo = getUserInfo($_SESSION['user_id']);
	
	if(isset($_REQUEST['item_id'])) {
		$item = getItem($_REQUEST['item_id']);
		$status = $item[0];
		if( $status === false ) { 
			get_page_advanced("message","com", array("name" => $userInfo[0], "title" => "Error!", "message" => "Item not found!"));
		} else {
			get_page_advanced("detail","item", array("name" => $userInfo[0], "item" => $item));
		}
	} else {
		get_page("message", array("redirect" => "../index.php"));
	}
	
} else {
	get_page("message", array("redirect" => "../index.php"));
}
?>
